/*
 * @Author: szx
 * @Date: 2022-01-05 12:48:35
 * @LastEditTime: 2022-01-05 12:55:57
 * @Description:
 * @FilePath: \leetcode\1500-1599\1576\1576.js
 */
/**
 * @param {string} s
 * @return {string}
 */
var modifyString = function (s) {
    const n = s.length;
    const arr = [...s];
    for (let i = 0; i < n; ++i) {
        if (arr[i] === '?') {
            for (let j = 0; j < 3; ++j) {
                if ((i > 0 && arr[i - 1] === String.fromCharCode('a'.charCodeAt() + j)) || (i < n - 1 && arr[i + 1] === String.fromCharCode('a'.charCodeAt() + j))) {
                    continue;
                }
                arr[i] = String.fromCharCode('a'.charCodeAt() + j);
                break;
            }
        }
    }
    return arr.join('');
};
